use crate::project::img_2_db::img_2_db;
use crate::project::multithreading;
use std::time::{Instant, Duration};
use futures::join;
use async_std::task;

pub mod project;

#[async_std::main]
async fn main() {
    mt_test1().await;
    mt_test2().await;
}

async fn img_2__() {
    img_2_db("mysql://root:Cqecloud-2021@192.168.0.131:3306/tmp", "C:\\Users\\Squbi\\Desktop\\tf").await;
}

async fn mt_test1() {
    let mut handle = None;
    let ins = Instant::now();
    for i in 0..10000 {
        let h = task::spawn(async move {
            multithreading::vec().push(i);
            println!(" v : {:?}", multithreading::vec());
            println!(" time : {} ms", ins.elapsed().as_millis());
        });
        handle = Some(h);
    }
    let h = handle.unwrap();
    join!(h);
}

async fn mt_test2() {
    let (s,h) = multithreading::init();
    for i in 0..10000 {
        let s = s.clone();
        let h = task::spawn(async move {
            s.send(Box::new(move |v| { v.push(i) })).await;
        });
    }
    join!(h);
}